
package com.lk.lkappearance.controller;

import com.lk.lkappearance.common.AbstractBaseController;
import com.lk.lkappearance.model.Meter;
import com.lk.lkappearance.model.Meter;
import com.lk.lkappearance.service.MeterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/api/meter")
public class MeterController extends AbstractBaseController {
    @Autowired
    private MeterService meterService;

    /**
     *
     * @param meter
     * @return
     */
    @RequestMapping(value="/getList" , method = RequestMethod.GET)
    public Map<String,Object> getList(@RequestBody Meter meter){
        log.info("获取仪表基础信息列表");
        return meterService.getList(meter);
    }

    /**
     * @param meterId
     * @return
     */
    @RequestMapping(value="/getByPrimaryKey", method = RequestMethod.POST)
    public Map<String,Object> selectByPrimaryKey(@RequestParam String meterId){
        log.info("查看仪表基础信息");
        return meterService.selectByPrimaryKey(meterId);
    }

    /**
     *
     * @param meter
     * @return
     */
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public Map<String,Object> add(@RequestBody Meter meter){
        log.info("添加仪表基础信息");
        return meterService.add(meter);
    }

    /**
     *
     * @param meter
     * @return
     */
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public Map<String,Object> update(@RequestBody Meter meter){
        log.info("修改仪表基础信息");
        return meterService.modify(meter);
    }

    /**
     *
     * @param meterId
     * @return
     */
    @RequestMapping(value = "/del", method = RequestMethod.POST)
    public Map<String,Object> delete(@RequestBody String meterId){
        log.info("根据主键删除仪表基础信息");
        return meterService.delete(meterId);
    }

    /**
     *
     * @param meterList
     * @return
     */
    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
    public Map<String,Object> insertList(@RequestBody List<Meter> meterList){
        log.info("导入");
        return meterService.insertListExcel(meterList);
    }

    /**
     * @param meter
     * @return
     */
    @RequestMapping(value="/exportExcel", method = RequestMethod.GET)
    public Map<String,Object> getListExcel(@RequestBody Meter meter){
        log.info("导出");
        return meterService.exportExcel(meter);
    }


}
